<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>监控中心 - 报警记录</title>

    <!-- Bootstrap Core CSS -->
    <link href="${request.getContextPath()}/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${request.getContextPath()}/public/dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${request.getContextPath()}/public/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!--嵌入头部跟菜单-->
        <#include "/inc/menu.html"/>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <h4 class="page-header">报警记录</h4>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
        <!-- /.row -->
        <div class="row">

            <div class="col-lg-12">
                <form role="form" action="${request.getContextPath()}/home/alam/query.do" method="post">
                    <div class="form-group input-group col-lg-2" style="float:left;padding-right:12px;">
                        <span class="input-group-addon">状态</span>
                        <select name="status" class="form-control">
                            <option value="-1">全部</option>
                            <option value="0">处理中</option>
                            <option value="1">已处理</option>
                        </select>
                    </div>

                    <div class="form-group input-group col-lg-2" style="float:left;padding-right:12px;">
                        <span class="input-group-addon">品种</span>
                        <select name="breed" class="form-control">
                            <option value="">全部</option>
                            <#list breeds as breed>
                            <option value="${breed}">${breed}</option>
                            </#list>
                        </select>
                    </div>

                    <div class="form-group input-group col-lg-3" style="float:left;padding-right:12px;">
                        <span class="input-group-addon">仓库</span>
                        <select name="warehouseId" class="form-control">
                            <option value="-1">全部</option>
                            <#list warehouses as wh>
                            <option value="${wh.id}">${wh.name}</option>
                            </#list>
                        </select>
                    </div>

                    <div class="form-group input-group">
                        <button type="submit" class="btn btn-success">查询</button>
                    </div>
                </form>

            </div>
            <!-- /.row -->

            
            <div class="col-lg-12">

                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>报警时间</th>
                                    <th>仓单编号</th>
                                    <th>所在仓库</th>
                                    <th>品种</th>
                                    <th>重量</th>
                                    <th>状态</th>
                                    <th>处理时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>

                                <#if alams??>
                                <#list alams as alam>
                                <tr <#if alam.status=0>class="danger"</#if> >
                                    <td>${alam.alamTime}</td>
                                    <td>${alam.receipt.no}</td>
                                    <td>${alam.receipt.warehouse.name}</td>
                                    <td>${alam.receipt.breed}</td>
                                    <td>${alam.receipt.goodsWeight}
                                        <#if alam.receipt.weightType=0>吨<#else>千克</#if>
                                    </td>
                                    <td>
                                        <#if alam.status=0>处理中<#else>已处理</#if>
                                    </td>
                                    <td>${alam.processTime?default("")}</td>
                                    <!--<td> <a href="#" data-toggle="modal" data-target="#alamInfo">详情</a> </td>-->
                                    <td> <a href="#" onclick="showInfo('${alam.id}');">详情</a> </td>
                                </tr>
                                </#list>
                                </#if>

                            </tbody>
                        </table>
                    </div>
                    <!-- /.table-responsive -->
                </div>

            </div>

        </div>
        <!-- /.row -->
                
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->



    <div class="modal fade" id="alamInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">报警详情</h4>
                </div>
                <div class="modal-body">
                    <img id="alam_image" class="img-responsive" src="">
                    <div class="row show-grid">
                        <div  class="col-md-6">报警时间：<span id="alam_time"></span> </div>
                        <div  class="col-md-6">处理状态：<span id="alam_status"></span></div>
                        <div  class="col-md-12">处理时间：<span id="alam_ds_time"></span></div>
                        <div  class="col-md-12">处理意见：<span id="alam_ds_desc"></span></div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>



    <!-- jQuery -->
    <script src="${request.getContextPath()}/public/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="${request.getContextPath()}/public/dist/js/sb-admin-2.js"></script>

    <script src="${request.getContextPath()}/public/js/date-util.js"></script>

    <script>

        function showInfo(alamId){

            var url="${request.getContextPath()}/home/alam/info.do";

            //获取报警记录详情信息
            $.post(url,{alamId:alamId},function(data){

                var alam = data.data;

                //显示报警数据
                $("#alam_image").attr('src', alam.captureImageUrl+'?' + Math.floor(Math.random()*100) );

                $("#alam_time").html(new Date(alam.alamTime).Format("yyyy-MM-dd hh:mm:ss"));
                var status_str = "处理中";
                if(alam.status==1) status_str="已处理";
                $("#alam_status").html(status_str);

                if(alam.processTime!=null){
                    $("#alam_ds_time").html(new Date(alam.processTime).Format("yyyy-MM-dd hh:mm:ss"));
                }

                $("#alam_ds_desc").html(alam.processDesc);

            },"json");

            //显示model
            $("#alamInfo").modal();
        }

    </script>

</body>

</html>
